import React, { Component } from 'react'
import PropTypes from 'prop-types';


export class Main extends Component {
  render() {
    const { list, activeId } = this.props;
    let newObj = list.find( item => {  //找到点击id一致的那一项数据，进项页面渲染
      return item.id === activeId
    })
    return (
      <div className='main'>
        <h3>{newObj && newObj.title}</h3>
        <p>{newObj && newObj.cont}</p>
      </div>
    )
  }
}

// 数据类型校验 
Main.propTypes = {
  list: PropTypes.array,
};

// 设置默认值 
Main.defaultProps = {
  list: []
};

export default Main